<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/bootstrap.min.js"></script>
    <script src="../../static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="../../static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <!--<script src="http://cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script>
    <script src="../../static/js/smoothscroll.js"></script>
    <script src="../../static/js/mking.js"></script>-->
    <link href="http://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet">
    <!--<link rel="stylesheet" href="../../static/css/heightlength.css">
    <link rel="stylesheet" href="../../static/css/mxjs.css">-->
    <link rel="stylesheet" href="../../static/datetimepicker/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="../../static/css/heightlength.css">
    <!--<link rel="stylesheet" href="../../static/css/mxjs.css">-->
<style>
    body{
        /*width: 100%;*/
        height: 100%;
    }
    *{
        color: grey;
    }
    .form-control {
        width: 40%;
        /*margin-left: 12%;*/
        display: flex;
        flex-direction: column;
    }
    label{
        width: 20%;
    }
</style>
</head>
<body id="bb">

        <div class="col-lg-12 mxlength">
            <div class="mx-1" >
                <span >当前位置>> <i id="show">项目异常信息查询</i></span>
                <span id="ret" style="float: right;margin-right: 3%;color: black" hidden onclick="cl()"><a ><i>返回</i></a></span>
            </div>
        </div>
        <div class="col-lg-12"  id="tj" style="margin-left: 20px">
        <span style="">请选择查询条件</span>
        <table width="100%" style="width: 700px; ">
            <tr>
                <td colspan="4"></td>
            </tr>
            <tr>
                <td style="text-align: right">开始时间:</td>
                <td><input style="width: 80%;color: grey" type="text" class="form-control form_datetime" id="statime" name="time"  placeholder=""></td>
                <td style="text-align:right ">结束时间:</td>
                <td><input type="text" style="width: 80%" class="form-control form_datetime" id="endtime" name="time" value=""  placeholder="" style="float: right"></td>
            </tr>
            <tr>
                <td colspan="3">请选择您需要查询的异常项目类别<span style="color: red">(*至少选择一项)</span></td>
            </tr>
            <tr>
                <td colspan="4">
                    <table>
                        <tr>
                            <td style="font-size: 15px;width:100%">
                                <#list li as li>
                                    <label class="fa"><input type="checkbox" name="xm" value="${li.idx}">${li.xmNam}</label>
                                </#list>
                            </td>
                        </tr>
                        <tr>
                            <label><input type="checkbox" id="selectAll">全选</label>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <button onclick="cx()" style="margin-left: 5%">查询</button>
        </div>
        <div class="col-lg-12  "  id="res" hidden>
                  <span style="">时间段：<i id="time"></i> &nbsp;&nbsp;异常项目名称:<i id="count" style="color: red"></i></span>
                  <span style="text-align: center">仅显示存在异常信息的结果</span>
            <div id="tb">

            </div>
        </div>
<script>
    $(function () {

        if (document.referrer=="") {
            $("#bb").hide();
            var hostname=location.hostname;
            var port=location.port;
            var trueUri="http://"+hostname+":"+port+"/dw/?sess=1";
            window.location.href=trueUri;
        }

       // alert(window.location.href);

    });
    $('.form_datetime').datetimepicker({
        minView: "month",  //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
        format : 'yyyy-mm-dd',//日期显示格式
        //  timeFormat:'',//时间显示格式
        //  todayBtn:  1,
        autoclose: 1,
        pickerPosition: 'bottom-left'
    });
    $('#selectAll').change(function(){
        $('.fa').children(':checkbox').prop('checked',$(this).is(':checked')?true:false);
    });
    function cx() {
        var ycxm=$("input[name='xm']:checked");
        var ycxms=[];
        var obj=new Object();
        var start=$("#statime").val();
        var end=$("#endtime").val();
        //debugger;
        if (start==null || start==undefined || start==""){
            alert("请选择开始时间");
            return false;
        }
        if (end==null || end==undefined || end=="") {
            alert("请选择结束时间");
            return false;
        }
        if (start==end) {
            alert("开始时间和结束时间一致，请重新选择");
            return false;
        }
        if (ycxm.length==0) {
            alert("项目信息必须选择一项");
            return false;
        }
        for (var i=0;i<ycxm.length;i++){
            ycxms[i]=ycxm[i]['value'];

        }
        ycxms=$.makeArray(ycxms);
        if (pd(start,end)) {
            $.ajax({
                url: 'ycxmcx',
                type: "POST",
                traditional: true,
                data: {ycxm: ycxms, start: start, end: end},
                success: function (data) {
                    $("#time").text(start + "--" + end);
                    $("#count").text(data.msg);
                    $("#tj").hide();
                    $("#res").show();
                    $("#tb").empty();
                    $("#show").text("项目异常查询结果");
                    $("#ret").show();
                    if (data.status != "false") {
                        var datas = data.data;
                        for (var i = 0; i < datas.length; i++) {
                            var s = datas[i].li;
                            var str = "<div style='margin-top: 3%;font-size: 15px'><span>异常项目分类:<i style='color: red'>" + datas[i].ycxm + "</i> " +
                                "查询结果：<i>共有" + s.length + "条结果</i></span>";
                            str += "<table style='width: 100%;' border='1' cellpadding='0' cellspacing='0'>" +
                                "<thead>" +
                                "<th>体检编码</th>" +
                                "<th>身份证号</th>" +
                                "<th width='70px'>姓名</th>" +
                                "<th width='40'>性别</th>" +
                                "<th width='40'>年龄</th>" +
                                "<th width='40'>部门</th>" +
                                "<th width='40'>工号</th>" +
                                "<th width='100px'>体检日期</th>\n" +
                                "<th>结论及建议</th>\n" +
                                "</thead>" +
                                "<tbody>";
                            //debugger;
                            $.each(s, function (commendIndex, comment) {
                                str += "<tr>" +
                                    "<td>" + comment['tjbm'] + "</td>" +
                                    "<td>" + comment['idc'] + "</td>" +
                                    "<td><a href='../tj/my?idx=" + comment['idx'] + "' target='_blank' >" + comment['name'] + "</td>" +
                                    "<td>" + comment['sex'] + "</td>" +
                                    "<td>" + comment['age'] + "</td>";
                                if (comment['dpt'] != null) {
                                    str += "<td>" + comment['dpt'] + "</td>";
                                } else {
                                    str += "<td></td>";
                                }
                                if (comment['wrknum'] != null) {
                                    str += "<td>" + comment['wrknum'] + "</td>";
                                } else {
                                    str += "<td></td>";
                                }
                                if (comment['bhkdat'] != null) {
                                    str += "<td>" + comment['bhkdat'] + "</td>";
                                } else {
                                    str += "<td></td>";
                                }
                                if (comment['tjjg'] != null || comment['jy'] != null) {
                                    str += "<td>" + comment['tjjg'] + "<br/>" + comment['jy'] + "</td>" +
                                        "</tr>";
                                } else {
                                    str += '<td>本次体检未结束，暂不能查询</td></tr>';
                                }
                            });
                            str += "</tbody></table></div>";
                            $("#tb").append(str);
                        }
                    } else {

                        $("#tb").append("<h2 style='font-size: 15px'>暂无体检异常信息</h2>");
                    }
                }
            })
        }else {
            alert("开始时间不能大于结束时间");
            return false;
        }
    }
    function  cl() {
        $("#tb").empty();
        $("#res").hide();
        $("#tj").show();
        $("#ret").hide();
        $("#time").empty();
        $("#count").empty();
    }
    function pd(start,end) {
        var startTmp = start.split("-");
        var endTmp = end.split("-");
        var stT = new Date(startTmp[0], startTmp[1], startTmp[2]);
        var edT = new Date(endTmp[0], endTmp[1], endTmp[2]);
        if (stT.getTime() >edT.getTime()) {
            //alert("开始日期不能大于或等于结束日期！");
            return false;
        }else {
            return true;
        }
    }
</script>
</body>
</html>